<template>
	<view class="wrap">
		<view class="store">
			<view class="store-logo">
				<image :src="shopInfo.logoImg"></image>
			</view>
			<view class="store-M">
				<view class="store-MT">
					<view class="store-name">{{shopInfo.name}}</view>
				</view>
				<view class="store-MB">
					<view class="store-level">
						<image v-for="(item,index) in 5" src="../../static/images/icon-level2.png"
							style="width: 24rpx;height: 20rpx;"></image>
					</view>
					<view class="store-follow">{{shopInfo.concernCount}}人关注</view>
				</view>
			</view>
		</view>
		<view class="appraise">
			<view class="appraise-header">
				<view class="appraise-header_title">店铺综合体验</view>
				<view class="appraise-header_star">
					<block v-for="(item, index) in [0,1,2,3,4]" :key="index">
						<image v-if="shopInfo.experienceScore > item" src="../../static/images/icon-star-active.png">
						</image>
						<image v-else src="../../static/images/icon-star.png"></image>
					</block>
				</view>
			</view>
			<view class="appraise-main">
				<view class="appraise-item">
					<view class="appraise-label">服务评分</view>
					<view class="appraise-progress">
						<view class="appraise-progress_active" :style="{width: `${shopInfo.serviceScoreWidth}rpx`}">
						</view>
					</view>
					<view class="appraise-score">
						<text>{{shopInfo.serviceScore}}</text>
						<text>持平于同行</text>
					</view>
				</view>
				<view class="appraise-item">
					<view class="appraise-label">商品评分</view>
					<view class="appraise-progress">
						<view class="appraise-progress_active" :style="{width: `${shopInfo.productScoreWidth}rpx`}">
						</view>
					</view>
					<view class="appraise-score">
						<text>{{shopInfo.productScore}}</text>
						<text>持平于同行</text>
					</view>
				</view>
				<view class="appraise-item">
					<view class="appraise-label">物流评分</view>
					<view class="appraise-progress">
						<view class="appraise-progress_active" :style="{width: `${shopInfo.logisticsScoreWidth}rpx`}">
						</view>
					</view>
					<view class="appraise-score">
						<text>{{shopInfo.logisticsScore}}</text>
						<text>持平于同行</text>
					</view>
				</view>
			</view>
		</view>
		<view class="base">
			<view class="base-header">基础信息</view>
			<view class="base-main">
				<!-- <view class="base-item">
					<view class="base-label">掌柜名</view>
					<view class="base-content">蜡笔小明</view>
				</view> -->
				<view class="base-item">
					<view class="base-label">所在地</view>
					<view class="base-content">{{shopInfo.address}}</view>
				</view>
				<!-- <view class="base-item">
					<view class="base-label">资质</view>
					<view class="base-content">21948元</view>
				</view> -->
				<view class="base-item" @click="onSkipTap('certificate')">
					<view class="base-label">企业资质</view>
					<view class="base-content app_arrow">查看营业执照</view>
				</view>
				<view class="base-item">
					<view class="base-label">开店时间</view>
					<view class="base-content">{{shopInfo.inTime}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shopInfo: {},
				userInfo: {}
			}
		},
		onLoad(options) {
			this.updatePage()
		},
		methods: {
			updatePage() {
				this.getStoreInfo()
			},
			onSkipTap(type, index) {
				const urlObj = {
					certificate: () => {
						if (this.shopInfo.license) {
							uni.navigateTo({
								url: `/pages/shopInfo/certificate?license=${this.shopInfo.license}`
							})
						} else {
							uni.showToast({
								title: '查询失败',
								icon: 'none'
							})
						}
					}
				}
				this.$g_util.navigationTo(urlObj, type)
			},
			getUserInfo() {
				this.$store.dispatch('updateUserInfo')
			},
			getStoreInfo() {
				this.$g_api.shopDetailShop().then(({
					data
				}) => {
					data.logoImg = this.$g_util.concatRequestUrl(data.logoImg)
					data.license = this.$g_util.concatRequestUrl(data.license)
					data.logisticsScoreWidth = 300 * data.logisticsScore / 5
					data.productScoreWidth = 300 * data.productScore / 5
					data.serviceScoreWidth = 300 * data.serviceScore / 5
					this.shopInfo = data
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.store {
		display: flex;
		align-items: center;
		padding: 30rpx;
		background-color: #fff;
	}

	.store-logo {
		font-size: 0;

		image {
			width: 90rpx;
			height: 90rpx;
			margin-right: 30rpx;
			border-radius: 10rpx;
			// background-color: #ccc;
		}
	}

	.store-M {
		flex: 1;
	}

	.store-MT {
		display: flex;
		align-items: center;
		margin-bottom: 8rpx;
	}

	.store-name {
		font-weight: bold;
		font-size: 30rpx;
		color: #333;
	}

	.store-MB {
		display: flex;
		align-items: center;
	}

	.store-level {
		margin-right: 20rpx;

		image {
			margin-right: 4rpx;
		}
	}

	.store-follow {
		font-size: 22rpx;
		color: #999;
	}

	.appraise {
		margin-top: 20rpx;
		padding: 30rpx;
		background-color: #fff;
	}

	.appraise-header {
		display: flex;
		align-items: center;
		margin-bottom: 40rpx;
	}

	.appraise-header_title {
		margin-right: 30rpx;
		font-weight: bold;
		font-size: 30rpx;
	}

	.appraise-header_star {
		display: flex;

		image {
			width: 24rpx;
			height: 24rpx;
			margin-right: 10rpx;
		}
	}

	.appraise-main {}

	.appraise-item {
		display: flex;
		align-items: center;
		margin-bottom: 34rpx;
	}

	.appraise-label {
		width: 134rpx;
	}

	.appraise-progress {
		position: relative;
		width: 300rpx;
		height: 16rpx;
		border-radius: 8rpx;
		background-color: #e6e6e6;
	}

	.appraise-progress_active {
		position: absolute;
		left: 0;
		top: 0;
		width: 0rpx;
		height: 16rpx;
		background: linear-gradient(90deg, #FFA64C, #FF7733);
		border-radius: 8rpx;
	}

	.appraise-score {
		margin-left: 30rpx;

		text {
			color: #FF7733;

			&:first-child {
				font-size: 26rpx;
			}

			&:last-child {
				margin-left: 20rpx;
				font-size: 22rpx;
			}
		}
	}

	.base {
		margin-top: 20rpx;
		padding: 30rpx;
		background-color: #fff;
	}

	.base-header {
		margin-bottom: 40rpx;
		font-size: 30rpx;
		font-weight: bold;
	}

	.base-main {}

	.base-item {
		display: flex;
		margin-bottom: 40rpx;
		font-size: 26rpx;

		&:last-child {
			margin-bottom: 0;
		}
	}

	.base-label {
		width: 152rpx;
		color: #999;
	}

	.base-content {
		flex: 1;
		color: #333;
	}
</style>
